package com.mirei.listener;

import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.ExchangeTypes;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;


/**
 * @author 监听fanout队列
 */
@Slf4j
@Component
public class FanoutListener {

    @RabbitListener(bindings = @QueueBinding(
            value = @Queue("boot.fanout.customer1"),
            exchange = @Exchange(name = "boot.fanout", type = ExchangeTypes.FANOUT)))
    public void listenFanoutQueue1(String msg) {
        log.info("消费者1收到[boot.fanout.customer1]队列的消息,内容:{}", msg);
    }

    @RabbitListener(bindings = @QueueBinding(
            value = @Queue("boot.fanout.customer2"),
            exchange = @Exchange(name = "boot.fanout", type = ExchangeTypes.FANOUT)))
    public void listenFanoutQueue2(String msg) {
        log.info("消费者2收到[boot.fanout.customer2]队列的消息,内容:{}", msg);
    }
}
